<template>
	<view class="messagePage myBackground">
		<view v-if="breakdownData.length > 0" class="content pl15 pr15">
			<scroll-view scroll-y class="h100p w100p">
				<view>
					<view class="mb15" v-for="(item,index) in breakdownData" :key="index">
						<view class="content_item p15 boxSizing">
							<view class="itemName pb15">
								<view class="d-flex a-center">
									<view class="line mr5"></view>
									<view>{{item.deviceTypeName}}</view>
								</view>
							</view>
							<view class="my_flex_sb mb15">
								<view class="rowName">合分动作:</view>
								<view class="rowValue">{{item.openStatus}}</view>
							</view>
							<view class="my_flex_sb mb15">
								<view class="rowName">状态:</view>
								<view class="rowValue" :class="tableColor[item.deviceStatus].color">
									{{tableColor[item.deviceStatus].name}}
								</view>
							</view>
							<view class="my_flex_sb mb15">
								<view class="rowName">操作人:</view>
								<view class="rowValue">{{item.operatorName}}</view>
							</view>
							<view class="my_flex_sb mb15">
								<view class="rowName">操作类型:</view>
								<view class="rowValue">{{item.operatorType=='person'?'远程控制':'系统控制'}}</view>
							</view>
							<view class="my_flex_sb mb15">
								<view class="rowName">下发时间:</view>
								<view class="rowValue">{{item.createTime}}</view>
							</view>
						</view>
					</view>
				</view>
				<view style="height: 10rpx;"></view>
			</scroll-view>
		</view>

		<view v-else class="w100p d-flex-center" style="height: calc(100% - 60px);">
			<noValue></noValue>
		</view>

		<!-- <tab-bar-view :tabCode="'1'"></tab-bar-view> -->
	</view>
</template>

<script>
	import {
		queryThreeBuildOneFloorEventByAppReport
	} from "@/api/dormBuilding/threeBuildOneFloor.js"
	import {
		queryThreeBuildTwoFloorEventByAppReport
	} from "@/api/dormBuilding/threeBuildTwoFloor.js"
	import {
		queryThreeBuildThreeFloorEventByAppReport
	} from "@/api/dormBuilding/threeBuildThreeFloor.js"
	import {
		queryThreeBuildFourFloorEventByAppReport
	} from "@/api/dormBuilding/threeBuildFourFloor.js"
	import {
		queryThreeBuildFiveFloorEventByAppReport
	} from "@/api/dormBuilding/threeBuildFiveFloor.js"

	import {
		querytwoBuildOneFloorEventByAppReport
	} from "@/api/dormBuilding/twoBuildOneFloor.js"
	import {
		querytwoBuildTwoFloorEventByAppReport
	} from "@/api/dormBuilding/twoBuildTwoFloor.js"
	import {
		querytwoBuildThreeFloorEventByAppReport
	} from "@/api/dormBuilding/twoBuildThreeFloor.js"
	import {
		querytwoBuildFourFloorEventByAppReport
	} from "@/api/dormBuilding/twoBuildFourFloor.js"
	import {
		querytwoBuildFiveFloorEventByAppReport
	} from "@/api/dormBuilding/twoBuildFiveFloor.js"

	import {
		queryoneBuildOneFloorEventByAppReport
	} from "@/api/dormBuilding/oneBuildOneFloor.js"
	import {
		queryoneBuildTwoFloorEventByAppReport
	} from "@/api/dormBuilding/oneBuildTwoFloor.js"
	import {
		queryoneBuildThreeFloorEventByAppReport
	} from "@/api/dormBuilding/oneBuildThreeFloor.js"
	import {
		queryoneBuildFourFloorEventByAppReport
	} from "@/api/dormBuilding/oneBuildFourFloor.js"
	import {
		queryoneBuildFiveFloorEventByAppReport
	} from "@/api/dormBuilding/oneBuildFiveFloor.js"

	import {
		queryOneFloorOneEventByAppReport
	} from "@/api/electrician/oneBulid.js"
	import {
		queryTwoFloorOneEventByAppReport
	} from "@/api/electrician/twoBulid.js"
	import {
		queryThreeFloorOneEventByAppReport
	} from "@/api/electrician/threeBulid.js"
	export default {
		data() {
			return {
				activeMenu: "",
				timeout: [],
				breakdownData: [],
				tableColor: [{
						color: '',
						name: ''
					},
					{
						color: 'table_color_success',
						name: '指令发送成功'
					},
					{
						color: 'table_color_primary',
						name: '指令发送成功等待核验'
					},
					{
						color: 'table_color_success',
						name: '操作成功'
					},
					{
						color: 'table_color_warning',
						name: '操作失败核验超时'
					},
					{
						color: 'table_color_danger',
						name: '故障分闸'
					}
				],
			};
		},
		onLoad(query) {
			this.activeMenu = query.activeMenu
		},
		onShow() {
			this.switchShowPage(this.activeMenu)

			this.setupTimer()
		},
		onReady() {
			// 隐藏导航栏
			uni.hideTabBar({});
		},
		onUnload() {
			this.clearTimer()
		},
		methods: {
			// 设置定时器
			setupTimer() {
				let _this = this;
				_this.timeout[0] = setInterval(() => {
					_this.switchShowPage(this.activeMenu)
				}, 15000);
			},
			// 清除定时器
			clearTimer() {
				let _this = this;
				if (_this.timeout.length > 0) {
					_this.timeout.forEach(item => {
						clearInterval(item);
					})
				}
			},

			switchShowPage(data) {
				const _this = this
				switch (data) {
					case '3-1':
						_this.queryThreeBuildOneFloorEventByAppReport()
						break;
					case '3-2':
						_this.queryThreeBuildTwoFloorEventByAppReport()
						break;
					case '3-3':
						_this.queryThreeBuildThreeFloorEventByAppReport()
						break;
					case '3-4':
						_this.queryThreeBuildFourFloorEventByAppReport()
						break;
					case '3-5':
						_this.queryThreeBuildFiveFloorEventByAppReport()
						break;
					case '2-1':
						_this.querytwoBuildOneFloorEventByAppReport()
						break;
					case '2-2':
						_this.querytwoBuildTwoFloorEventByAppReport()
						break;
					case '2-3':
						_this.querytwoBuildThreeFloorEventByAppReport()
						break;
					case '2-4':
						_this.querytwoBuildFourFloorEventByAppReport()
						break;
					case '2-5':
						_this.querytwoBuildFiveFloorEventByAppReport()
						break;
					case '1-1':
						_this.queryoneBuildOneFloorEventByAppReport()
						break;
					case '1-2':
						_this.queryoneBuildTwoFloorEventByAppReport()
						break;
					case '1-3':
						_this.queryoneBuildThreeFloorEventByAppReport()
						break;
					case '1-4':
						_this.queryoneBuildFourFloorEventByAppReport()
						break;
					case '1-5':
						_this.queryoneBuildFiveFloorEventByAppReport()
						break;
					case 'dg-1':
						_this.queryOneFloorOneEventByAppReport()
						break;
					case 'dg-2':
						_this.queryTwoFloorOneEventByAppReport()
						break;
					case 'dg-3':
						_this.queryThreeFloorOneEventByAppReport()
						break;
					default:
						// 如果 expression 不匹配任何 case 值，则执行 default 子句中的代码块  
						break;
				}
			},

			async queryThreeBuildOneFloorEventByAppReport() {
				await queryThreeBuildOneFloorEventByAppReport().then(res => {
					let tempData = res.object || []

					this.breakdownData = tempData
				})
			},
			async queryThreeBuildTwoFloorEventByAppReport() {
				await queryThreeBuildTwoFloorEventByAppReport().then(res => {
					let tempData = res.object || []

					this.breakdownData = tempData
				})
			},
			async queryThreeBuildThreeFloorEventByAppReport() {
				await queryThreeBuildThreeFloorEventByAppReport().then(res => {
					let tempData = res.object || []

					this.breakdownData = tempData
				})
			},
			async queryThreeBuildFourFloorEventByAppReport() {
				await queryThreeBuildFourFloorEventByAppReport().then(res => {
					let tempData = res.object || []

					this.breakdownData = tempData
				})
			},
			async queryThreeBuildFiveFloorEventByAppReport() {
				await queryThreeBuildFiveFloorEventByAppReport().then(res => {
					let tempData = res.object || []

					this.breakdownData = tempData
				})
			},
			async querytwoBuildOneFloorEventByAppReport() {
				await querytwoBuildOneFloorEventByAppReport().then(res => {
					let tempData = res.object || []

					this.breakdownData = tempData
				})
			},
			async querytwoBuildTwoFloorEventByAppReport() {
				await querytwoBuildTwoFloorEventByAppReport().then(res => {
					let tempData = res.object || []

					this.breakdownData = tempData
				})
			},
			async querytwoBuildThreeFloorEventByAppReport() {
				await querytwoBuildThreeFloorEventByAppReport().then(res => {
					let tempData = res.object || []

					this.breakdownData = tempData
				})
			},
			async querytwoBuildFourFloorEventByAppReport() {
				await querytwoBuildFourFloorEventByAppReport().then(res => {
					let tempData = res.object || []

					this.breakdownData = tempData
				})
			},
			async querytwoBuildFiveFloorEventByAppReport() {
				await querytwoBuildFiveFloorEventByAppReport().then(res => {
					let tempData = res.object || []

					this.breakdownData = tempData
				})
			},
			async queryoneBuildOneFloorEventByAppReport() {
				await queryoneBuildOneFloorEventByAppReport().then(res => {
					let tempData = res.object || []

					this.breakdownData = tempData
				})
			},
			async queryoneBuildTwoFloorEventByAppReport() {
				await queryoneBuildTwoFloorEventByAppReport().then(res => {
					let tempData = res.object || []

					this.breakdownData = tempData
				})
			},
			async queryoneBuildThreeFloorEventByAppReport() {
				await queryoneBuildThreeFloorEventByAppReport().then(res => {
					let tempData = res.object || []

					this.breakdownData = tempData
				})
			},
			async queryoneBuildFourFloorEventByAppReport() {
				await queryoneBuildFourFloorEventByAppReport().then(res => {
					let tempData = res.object || []

					this.breakdownData = tempData
				})
			},
			async queryoneBuildFiveFloorEventByAppReport() {
				await queryoneBuildFiveFloorEventByAppReport().then(res => {
					let tempData = res.object || []

					this.breakdownData = tempData
				})
			},
			async queryOneFloorOneEventByAppReport() {
				await queryOneFloorOneEventByAppReport().then(res => {
					let tempData = res.object || []
			
					this.breakdownData = tempData
				})
			},
			async queryTwoFloorOneEventByAppReport() {
				await queryTwoFloorOneEventByAppReport().then(res => {
					let tempData = res.object || []
			
					this.breakdownData = tempData
				})
			},
			async queryThreeFloorOneEventByAppReport() {
				await queryThreeFloorOneEventByAppReport().then(res => {
					let tempData = res.object || []
			
					this.breakdownData = tempData
				})
			},
			goPage(url) {
				uni.navigateTo({
					url
				});
			},
		},
	};
</script>

<style lang="scss" scoped>
	page {
		background-color: #f5f5f5;
	}

	.messagePage {
		height: calc(100vh - var(--window-top));
		width: 100%;

		.content {
			display: flex;
			flex-direction: column;
			height: calc(100% - 20rpx);
			font-family: Source Han Sans CN, Source Han Sans CN-400;

			.content_item {
				background: #ffffff;
				border-radius: 8px;
				box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.10);
				font-family: "黑体", "Heiti SC", "STHeiti", sans-serif;

				.line {
					width: 12rpx;
					height: 32rpx;
					background: #3276FF;
					border-radius: 3px;
				}

				.itemName {
					font-size: 32upx;
					color: #333333;
					font-weight: 600;
				}

				.rowName {
					font-size: 28upx;
					color: #333333;
				}

				.rowValue {
					font-size: 28upx;
					color: #666666;
				}

				.table_color_success {
					color: #07C160;
				}

				.table_color_warning {
					color: #debc10;
				}

				.table_color_danger {
					color: #e30a35;
				}

				.table_color_primary {
					color: #0755b4;
				}
			}

			.my_flex_sb:last-child {
				margin-bottom: 0 !important;
			}
		}
	}
</style>